<template>
  <div class="jvm">
    <el-tabs type="border-card">
      <el-tab-pane :label="$t('tabs.jvm.configurations')">
        <all-sort-and-search-table :columns="jvmColumns" @getData="getJvmData"/>
      </el-tab-pane>
      <el-tab-pane :label="$t('tabs.jvm.classes')">
        <all-sort-and-search-table :columns="classColumns" @getData="getClass"/>
      </el-tab-pane>
      <el-tab-pane :label="$t('tabs.jvm.jars')">
        <all-sort-and-search-table :columns="jarColumns" @getData="getJar"/>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import baseinfoApi from "@/serveapi/baseinfoApi.js";
import AllSortAndSearchTable from "@/components/Table/AllSortAndSearchTable.vue";
import commonUtil from "@/utils/commonUtil.js";
export default {
  components: {
    AllSortAndSearchTable
  },
  data() {
    return {
      activitiName: "jvmProperties",
      jvmColumns: [
        {
          key: "key",
          label: "名称",
          width: 230,
          labelEn:'property key'
        },
        {
          key: "value",
          label: "属性",
          labelEn:'property value'
        }
      ],
      classColumns: [
        {
          key: "simpleClassName",
          label: "类名",
          width: 230,
          labelEn:'simpleClassName'
        },
        {
          key: "classLoaderName",
          label: "类加载器",
          width: 230,
          labelEn:'classLoaderName',
          enSelectAble: true
        },
        {
          key: "className",
          label: "全类名",
          labelEn:'className'
        }
      ],
      jarColumns: [
         {
          key: "jarName",
           label: "名称",
          width: 230,
           labelEn:'jarName'
        },
        {
          key: "jarPath",
          label: "路径",
          labelEn:'jarPath'
        }

      ]
    };
  },
  methods: {
    async getJvmData(setData, searchOver) {
      try {
        let jvmPropertieMap = await baseinfoApi.getJvmProperties();
        let list = commonUtil.mapToList(jvmPropertieMap);
        setData(list);
      } finally {
        searchOver();
      }
    },
    async getClass(setData, searchOver) {
      try {
        let list = await baseinfoApi.getClassLoaderClasses();
        setData(list);
      } finally {
        searchOver();
      }
    },
    async getJar(setData, searchOver) {
      try {
        let list = await baseinfoApi.getJars();
        setData(list);
      } finally {
        searchOver();
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.jvm {
  margin: 30px;
}
</style>
